import React, { Component } from 'react'
import { Layout } from 'antd';
import { Menu, Button } from 'antd';
import Table from './table';
import Chart from './chart';
import RouterView from '../router/routerView';
import routterList from '../router/routerList';
import BackHeader from "./goBackHeader" // exoort default 抛出的东西在其他文件引入时名字随便起
import { Route, Switch, NavLink, Link ,Redirect,BrowserRouter} from 'react-router-dom'
import {
    AppstoreOutlined,
    MenuUnfoldOutlined,
    MenuFoldOutlined,
    PieChartOutlined,
    DesktopOutlined,
    ContainerOutlined,
    MailOutlined,
  } from '@ant-design/icons';
const { SubMenu } = Menu;

const { Header, Footer, Sider, Content } = Layout;
 class App extends Component {
    state = {
       collapsed: 'false',
    };

    toggleCollapsed = (aaa) => {
        console.log(aaa);
        this.setState({
            collapsed: !aaa,
        });
    }; 
    
  render() {
    return (
      <div>
           <BrowserRouter>
        <Layout>
            <Header>
                <BackHeader></BackHeader>
            </Header>
            <Layout>
                <Sider>
                
                <Menu
                    defaultSelectedKeys={['1']}
                    defaultOpenKeys={['sub1']}
                    mode="inline"
                    theme="dark"
                    collapsed={this.state.collapsed}
                >
                        <Menu.Item key="1" icon={<PieChartOutlined />}>
                           <NavLink to="/chart">图标</NavLink>
                        </Menu.Item>
                        <Menu.Item key="2" icon={<DesktopOutlined />}>
                        <NavLink to="/table">表格</NavLink>
                        </Menu.Item>
                        <Menu.Item key="3" icon={<ContainerOutlined />}>
                        Option 3
                        </Menu.Item>
                        <SubMenu key="sub1" icon={<MailOutlined />} title="Navigation One">
                        <Menu.Item key="5">Option 5</Menu.Item>
                        <Menu.Item key="6">Option 6</Menu.Item>
                        <Menu.Item key="7">Option 7</Menu.Item>
                        <Menu.Item key="8">Option 8</Menu.Item>
                        </SubMenu>
                        <SubMenu key="sub2" icon={<AppstoreOutlined />} title="Navigation Two">
                        <Menu.Item key="9">Option 9</Menu.Item>
                        <Menu.Item key="10">Option 10</Menu.Item>
                        <SubMenu key="sub3" title="Submenu">
                            <Menu.Item key="11">Option 11</Menu.Item>
                            <Menu.Item key="12">Option 12</Menu.Item>
                        </SubMenu>
                        </SubMenu>
                    </Menu>
                </Sider>
                <Content>
                         <RouterView RoutterList={routterList}></RouterView>
                        {/* <Switch>
                            <Route path="/chart" component={Chart}></Route>
                            <Route path="/table" component={Table}></Route>
                            <Redirect from="/" to="/chart"></Redirect>
                        </Switch> */}
                  
                </Content>
            </Layout>

        </Layout>
        </BrowserRouter>
      </div>
    )
  }
}

export default App